#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/12/13 3:03
# @Author  : lizhen
# @Site    : 
# @File    : cQRCode.py
# @Software: PyCharm
import qrcode


class QRCodeDemo:
    def gen_qrcode(self, url, pic):
        website = url
        qr = qrcode.QRCode(version=1,
                           error_correction=qrcode.constants.ERROR_CORRECT_L,
                           box_size=8,
                           border=8,
                           )
        qr.add_data(website)
        qr.make(fit=True)
        img = qr.make_image()
        img.save(pic)

    def _test_gen_qrcode(self):
        """
        qd = QRCodeDemo()
        qd._test_gen_qrcode()
        """
        qd = QRCodeDemo()
        qd.gen_qrcode('https://www.baidu.com/', 'ext/cQRCode/qrcode.png')


if __name__ == '__main__':
    qd = QRCodeDemo()
    qd._test_gen_qrcode()
